const  express  =  require("express")
const  router  =  express.Router()
const conn = require("../mysql")


// tab切换
router.get('/user', (req, res) => {
    let { tom } = req.query
    let sql = `select * from cat_mao1 where num='${tom}'`
    console.log(sql)
    let result = {}
    conn.query(sql, (err, data) => {
        //错误
        if (err) {
            console.log('错误')
            return;
        }
        //查找到结果 [] [{}] [{},{},{}]
        if (data.length) {
            result = {
                code: 1,
                data
            }
        } else {
            result = {
                code: 0
            }
        }
        res.send(result)
    })

})
router.get('/goodsa', (req, res) => {
    let { tom } = req.query
    let sql = `select * from cat_mao where num='${tom}'`
    console.log(sql)
    let result = {}
    conn.query(sql, (err, data) => {
        //错误
        if (err) {
            console.log('错误')
            return;
        }
        //查找到结果 [] [{}] [{},{},{}]
        if (data.length) {
            result = {
                code: 1,
                data
            }
        } else {
            result = {
                code: 0
            }
        }
        res.send(result)
    })

})
router.get('/goodsb', (req, res) => {
    let { tom } = req.query
    let sql = `select * from cat_mao where num='${tom}'`
    console.log(sql)
    let result = {}
    conn.query(sql, (err, data) => {
        //错误
        if (err) {
            console.log('错误')
            return;
        }
        //查找到结果 [] [{}] [{},{},{}]
        if (data.length) {
            result = {
                code: 1,
                data
            }
        } else {
            result = {
                code: 0
            }
        }
        res.send(result)
    })

})
router.get('/goodsc', (req, res) => {
    let { tom } = req.query
    let sql = `select * from cat_mao where num='${tom}'`
    console.log(sql)
    let result = {}
    conn.query(sql, (err, data) => {
        //错误
        if (err) {
            console.log('错误')
            return;
        }
        //查找到结果 [] [{}] [{},{},{}]
        if (data.length) {
            result = {
                code: 1,
                data
            }
        } else {
            result = {
                code: 0
            }
        }
        res.send(result)
    })

})
router.get('/goodsd', (req, res) => {
    let { tom } = req.query
    let sql = `select * from cat_mao where num='${tom}'`
    console.log(sql)
    let result = {}
    conn.query(sql, (err, data) => {
        //错误
        if (err) {
            console.log('错误')
            return;
        }
        //查找到结果 [] [{}] [{},{},{}]
        if (data.length) {
            result = {
                code: 1,
                data
            }
        } else {
            result = {
                code: 0
            }
        }
        res.send(result)
    })

})

module.exports  =  router;